package com.rc.exception;

import com.rc.entity.web.Result;
import com.rc.util.HttpCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ServiceException.class)
    public Result handelServiceException(ServiceException se){
        return Result.ERROR(se.getCode(),se.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result handleGeneralException(Exception ex){
        return Result.ERROR(HttpCode.SERVICE_ERROR.getCode(),ex.getMessage());
    }
}
